<html>
<head>
   <script src="../../Grid/GridE.js"> </script>
</head>
<body class="Tutorial">
   <style>
      /* Tutorial shared styles */
      .Tutorial h1,.Tutorial h2,.Tutorial ul,.Tutorial .Desc,.Tutorial .Path,.Tutorial .Xml { max-height:999999px; }
      .Tutorial h1 { font:30px Arial; padding:5px 0px 5px 0px; margin:0px; text-align:center; }
      .Tutorial h2 { font:15px Arial; padding:0px; margin:0px 0px 10px 0px; text-align:center; color:#757575; }
      .Tutorial h3,.Tutorial h4 { display:inline-block; font:bold 15px Arial; padding:0px 5px 0px 5px; border-radius:2px; color:black; margin:2px; font-style:normal; color:#333; }
      .Tutorial h3 { background:#EE9; border:1px solid #DD8; }
      .Tutorial h4 { background:#BDE; border:1px solid #ACD; }
      .Tutorial a { text-decoration:underline; }      
      .Tutorial li { padding-bottom:8px; }
      .Tutorial ul { margin:6px 0px 0px 20px; font:13px Arial; }
      .Tutorial > ul { margin-left:0px; padding-left:15px; clear:both; }
      .Tutorial ul b { color:#0585B9; }
      .Tutorial .Path { font:normal 12px Arial; color:#0585B9; }
      .Tutorial .Path b { color:#D73938; }
      .Tutorial .Path u { text-decoration:none; color:black; font-weight:bold; padding:0px 2px 0px 2px; }
      .Tutorial .Xml { margin-bottom:6px; font-size:12px; color:#757575; }
      .Tutorial .Border { border:1px solid #dfdfdf; padding:10px 20px 10px 20px; margin:0px 8px 20px 0px; min-width:100%; box-sizing:border-box; overflow:hidden; }
      .Tutorial .Main { }
   </style>

   <center class="Path"><script>document.write(location.href.replace(/(.*)(\/Tutorials\/)([^\/]+)\/([^\/]+)$/,"$2<b>$3</b>/$4").replace(/([^<]|^)(\/|\.)/g,"$1<u>$2</u>"));</script></center>
   <h1>4. Master detail tables</h1>
   <h2>Master detail relation in plain tables</h2>

   <center class="Border" id="Border">
      <div style="width:775px;">
         <div style="float:left; margin-right:10px;">
            <div class="Xml">Source: <a href='04-Master.xml'>04-Master.xml</a></div>
            <div class="Main" style='width:475px; height:320px;'>
               <bdo Debug='check' Data_Url='04-Master.xml'></bdo>
            </div>
         </div>
         <div style="float:left;">
            <div class="Xml">Source: <a href='04-Detail.xml'>04-Detail.xml</a></div>
            <div class="Main" style='width:290px; height:320px;'>
               <bdo Debug='check' Data_Url='04-Detail.xml'></bdo>
            </div>
         </div>
      </div>
   </center>

   <ul>
      <li>
         Plain master detail relation is used to show the same data in two or more grids in different layout.<br />
         <b>Master</b> grid shows the data in rows and <b>detail</b> grid shows the one master row data in different structure, often vertically in column.<br />
      </li>
      <li>
         The data are defined only in master grid, only master grid stores the changes and can upload them back to server.<br />
         Detail grid defines only layout, the columns and fixed (summary) rows and optionally variable rows shown only when the detail grid is empty (does not show any master row).<br />
      </li>
      <li>
         The master relation is defined usually in <b>master default row &lt;D></b> definition.<br />
         This default row defines attributes for all the master root rows and also their hidden children to be displayed in detail grid.<br />
      </li>
      <li>
         The default row name should not be 'R', because it will be used for the children by default.<br /> 
         The default row name can be set to &lt;Root CDef/> attribute value to be used for all existing and new root rows in master grid.<br />
      </li>
      <li>
         The &lt;D> has set its attribute <h3>Detail</h3> as id of the detail grid where the row's children will be shown. The Detail marks the row as master row.<br />
         It should have set also <b>Expanded='0' CanExpand='0'</b> to never show its chilren in master grid.<br />
      </li>
      <li>
         The &lt;D> cell attributes <h3>CopyTo</h3> will define which master cells will be copied to which detail row(s) and cells.<br />
         Usual value of the master CopyTo attribute is "Child_X,Y", where X is child row position from 0 and Y is column name.<br />
         For example NAMECopyTo='Child_2,VALUE' means that master row's NAME cell will be copied to the third child row, to the cell name VALUE.<br />
      </li>
      <li>
         The &lt;D> defines children that will be shown in detail grid. Defines them as nested &lt;I> tags.<br />
         These child rows will be shown in detail grid, so they define cells in detail grid columns, not in master's.<br />
         These &lt;I> tags can have any standard row or cell attribute, also Def attribute to specify row default.<br />
      </li>
      <li>
         The child row cell attributes <h3>CopyTo</h3> will define which detail cells will be copied to which master cells.<br />
         Usual value of the child CopyTo attribute is "Parent,Y", where Y is the master cell name.<br />
         For example VALUECopyTo='Parent,NAME' means that child row's VALUE cell will be copied to the master row's cell NAME.<br />
      </li>
      <li>
         <h4>How it works</h4><br />
         <ul>
            <li>
               On master grid load there will be created hidden children for every row according to the &lt;D> definition.<br />
               To these children attributes will be copied values from the root rows, according to the &lt;D> <b>CopyTo</b> attributes.<br />
            </li>
            <li>
               When some row in master grid is chosen to show it in detail grid (e.g. focused), all the row's children are copied from master grid to detail grid and here are shown.<br />
               In this time are all the child rows at two placed (in master grid and in detail grid) and all changes are synchronized and mirrored to both.<br />
            </li>
            <li>
               When a user changes some value in master grid, in root row, the change is automatically copied to its hidden children and also mirrored to detail grid.<br />
               It is done by <b>CopyTo</b> attribute in &lt;D> tag, similarly to the grid loading.<br />
            </li>
            <li>
               When a user changes some value in detail grid, the change is mirrored to hidden child in master grid and also copied to the parent row.<br />
               It is done by <b>CopyTo</b> attribute in &lt;D> child &lt;I> tag.<br />
            </li>
            <li>
               When a user chooses another row in master grid to show it in detail grid, all actual detail grid variable rows are cleared and filled by the new content.<br />
            </li>
         </ul>
      </li>
      <li>
         The behavior of choosing master row to show in detail row can be controlled by assigning <b>ShowDetail</b> action to appropriate event.<br />
         Or simply by Cfg attribute <b>DetailOn</b> - 0 - disabled, 1 - on focus to row, 2 - on click to row, 3 - on double click to row.<br />
      </li>
      <li>
         <h4>API</h4><br />
         On showing the master row in detail grid is called API event <b>OnShowDetail</b>.<br />
         After the row is shown is called <b>OnShowDetailFinish</b>.<br />
         To manually show some master row in detail grid call API method <b>ShowDetail</b>.<br />
         To refresh or clear detail grid call <b>RefreshDetail</b>.<br />
      </li>
   </ul>

   <!-- Google Analytics code run once for trial -->
   <script>
      var TGTrial = document.cookie.match(/TGTrialMaster\s*=\s*(\d+)/), TGIndex = 8;
      if(!TGTrial||!(TGTrial[1]&TGIndex)) setTimeout(function(){
         var n = "RunTrialGridMaster4", d = (new Date((new Date).getTime()+31536000000)).toUTCString(); document.cookie = "TGTrialMaster="+((TGTrial?TGTrial[1]:0)|TGIndex)+";expires="+d;
         var u = document.cookie.match(/TGTrialUsed\s*=\s*(\d+)/); u = u ? u[1]-0+1 : 1; if(u<=11) document.cookie = "TGTrialUsed="+u+";path=/;expires="+d;
         var s = "<div style='width:0px;height:0px;overflow:hidden;'><iframe src='http"+(document.location.protocol=="https"?"s":"")+"://www.treegrid.com/Stat/GA.html?productName="
               +(u==1||u==3||u==5||u==10?"UsedTrial"+u:n)+"' onload='var T=this;setTimeout(function(){document.body.removeChild(T.parentNode.parentNode);},1000);'/></div>";
         var F = document.createElement("div"); F.innerHTML = s; document.body.appendChild(F);
         },100);
   </script>
</body>
</html>